import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';

class HomePage extends StatelessWidget {
  TextEditingController _searchTextEditingController =
      new TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Scaffold(
        appBar: AppBar(
          backgroundColor: Colors.white,
          title: Text(
            'HomePage',
            style: TextStyle(color: Colors.blue),
          ),
        ),
        body: Container(
          padding: const EdgeInsets.only(top: 20.0),
          alignment: Alignment.center,
          child: Column(
            children: <Widget>[
              _searchBar(),
            ],
          ),
        ),
      ),
    );
  }

  //搜索栏
  Widget _searchBar() {
    return Container(
      width: ScreenUtil.getInstance().setWidth(600),
      child: TextField(
        controller: _searchTextEditingController,
        decoration: InputDecoration(
          labelText: "搜索图书",
          hintText: "请输入需要搜索的图书名",
          prefixIcon: Icon(Icons.book),
          suffixIcon: InkWell(
            onTap: () {
              Fluttertoast.showToast(
                  msg: '${_searchTextEditingController.text}',
                  toastLength: Toast.LENGTH_SHORT,
                  gravity: ToastGravity.BOTTOM,
                  textColor: Colors.blue,
                  timeInSecForIos: 1,
                  fontSize: 16,
                  backgroundColor: Colors.white30);
            },
            child: Icon(Icons.search),
          ),
        ),
      ),
    );
  }
}
